package com.songhq.netty.one;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

public class OioDemo {
	
	
	@SuppressWarnings("resource")
	public static void main(String[] args) throws IOException {
		
		ServerSocket serverSocket = new ServerSocket(8080);
		Socket clientSocket = serverSocket.accept();
		//获取客户端的字符流输入流，字节流转换成字符流
		BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
		//直接输出字符流
		PrintWriter out = new PrintWriter(clientSocket.getOutputStream(),true);
		Scanner scanner = new Scanner(System.in);
		String request,response;
		while(true){
			request =in.readLine();
			System.out.println(request);
			
			String nextLine = scanner.nextLine();
			//scanner.close();
			out.println(nextLine);
			
		}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
	}

}
